package com.saybiu.controller;

import com.saybiu.domain.Like;
import com.saybiu.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author wangwei
 * @Date 2021/4/21 15:11
 * @Version 1.0
 */
@RestController
public class LikeController {
    @Resource
    private UserService userService;
    //查询点赞信息(userid)正向查
    //查询被赞信息(userid)反向查

    /**
     * 正向查询点赞信息
     * @param userId 用户id
     * @return
     */
    @GetMapping(value = "/likes")
    public List<Like> selectLike(Integer userId){
        //token获取userId
        List<Like> likes = userService.queryUserLikeAndBeLiked(userId, null);
        return  likes;
    }

    /**
     * 查询被点赞信息(反向)
     * @param beSupportedUserId 用户id
     * @param  userId 无用
     * @return
     */
    @GetMapping(value = "/likes/{beSupportedUserId}")
    public List<Like> selectBeLike(@PathVariable("beSupportedUserId")Integer beSupportedUserId,  Integer userId){
        //token获取userId
        List<Like> likes = userService.queryUserLikeAndBeLiked(null, beSupportedUserId);
        return likes;
    }

}
